package com.kavitha.learn.spring.anno;

import java.sql.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

	@SuppressWarnings({ "resource"})
	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
		EmployeeDAO employeeDAO1 = context.getBean(EmployeeDAO.class);
		System.out.println(employeeDAO1.getAllEmployees());
		Employee employee1 = new Employee();
		employee1.setDob(new Date(System.currentTimeMillis()));
		employee1.setEmailId("v@v.com");
		employee1.setFirstName("Vijayan-good");
		employee1.setLastName("Srinivasan");
		employee1.setPhoneNo("11");
		
		
		Employee employee2 = new Employee();
		employee2.setDob(new Date(System.currentTimeMillis()));
		employee2.setEmailId("v2@v.com");
		employee2.setFirstName("Vijayan2");
		employee2.setLastName("Srinivasan2");
		employee2.setPhoneNo("11277777777777777777777777777777777777777777777777777777777777777777");
		
		List<Employee> employees = Arrays.asList(employee1, employee2);
		try{
		employeeDAO1.insertEmployees(employees);
		}catch(Exception e){
			e.printStackTrace();
		}
		System.out.println(employeeDAO1.getAllEmployees());
		
	}

}
